export const mixins = {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      hzname: '',
      hzbh: '',
      jcbh: '',
      jcdjh: '',
      jianguanj2hover: false,
      jianguanj21hover: true,
      kv: 65,
      mas: 1.5,
      ms: 100,
      ma: 0,
      bgtips: '',
      bgtipstwo: '',
      wtext: '',
      tiptext: '',
      jlstips: '',
      jlstipstwo: '',
      taskdata: [
        {
          id: 1,
          name: '选择检测设备及模体'
        },
        {
          id: 2,
          name: '取出滤线栅'
        },
         {
          id: 3,
          name: '调节SID'
        },
        {
          id: 4,
          name: '放置检测设备及模体'
        },
       
        {
          id: 5,
          name: '调整照射野'
        },
        {
          id: 6,
          name: '放置铜板'
        },
        {
          id: 7,
          name: '工作站操作'
        },
        {
          id: 8,
          name: '记录空气比释动能值'
        },
        {
          id: 9,
          name: '获取预处理图像'
        },
       
        {
          id: 10,
          name: '测量像素平均值'
        },
         {
          id: 11,
          name: '计算数值'
        }
      ],
      jboxdata: [
        {
          id: 1,
          bsid: 1,
          name: '检测方法'
        },
        
      ],
      wpdata: [
        {
          id: 1,
          name: '笔记本电脑',
          src: require('@/images/wp1.png')
        },
        {
          id: 2,
          name: '多探测器XR',
          src: require('@/images/wp2.png')
        },
        {
          id: 3,
          name: '数据转换器',
          src: require('@/images/wp3.png')
        },
        {
          id: 4,
          name: '20mm铝板',
          src: require('@/images/wp11.png')
        },
        {
          id: 5,
          name: '铅板',
          src: require('@/images/wp5.png')
        },
        {
          id: 6,
          name: '1.0mm铜板',
          src: require('@/images/wp6.png')
        },
        {
          id: 7,
          name: '1.5mm铜板',
          src: require('@/images/wp7.png')
        },
        {
          id: 8,
          name: '准直度检测板',
          src: require('@/images/wp8.png')
        },
        {
          id: 9,
          name: '线束垂直度测试筒',
          src: require('@/images/wp9.png')
        },
        {
          id: 10,
          name: '毫米级刻度铅尺',
          src: require('@/images/wp10.png')
        },
        {
          id: 11,
          name: '铅板(15cm*15cm*2mm)',
          src: require('@/images/wp11.png')
        },
        {
          id: 12,
          name: '铅块(4cm*4cm*4mm)',
          src: require('@/images/wp12.png')
        },
        {
          id: 13,
          name: '屏片X射线密着检测板',
          src: require('@/images/wp13.png')
        },
        {
          id: 14,
          name: '高对比分辨力测试卡',
          src: require('@/images/wp14.png')
        },
        {
          id: 15,
          name: '低对比分辨力检测模体',
          src: require('@/images/wp15.png')
        },
        {
          id: 16,
          name: '胶带',
          src: require('@/images/wp16.png')
        }
      ],
      homedata: [
        {
          id: 1,
          name: '管电压指示的偏离检测'
        },
        {
          id: 2,
          name: '辐射输出重复性检测'
        },
        {
          id: 3,
          name: '输出量线性检测'
        },
        {
          id: 4,
          name: '有用线束半值层检测'
        },
        {
          id: 5,
          name: '曝光时间指示的偏离检测'
        }
      ],
      ycldata:[
          {
            src: require(`@/images/ycl1.png`)
          },
           {
            src: require(`@/images/ycl2.png`)
          },
            {
            src: require(`@/images/ycl3.png`)
          }
          
      ],
      yclimgid:1
    }
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {
    // 监听四个输入框
    hzname: {
      handler(i) {
        if (i != '') {
          this.clearmbfn()
        }
        if (i != '' && this.hzbh != '' && this.jcbh != '' && this.jcdjh != '') {
          this.taskids = 6.3
        }
      },
      deep: true,
      immediate: true
    },
    hzbh: {
      handler(i) {
        if (i != '') {
          this.clearmbfn()
        }
        if (
          i != '' &&
          this.hzname != '' &&
          this.jcbh != '' &&
          this.jcdjh != ''
        ) {
          this.taskids = 6.3
        }
      },
      deep: true,
      immediate: true
    },
    jcbh: {
      handler(i) {
        if (i != '') {
          this.clearmbfn()
        }
        if (
          i != '' &&
          this.hzbh != '' &&
          this.hzname != '' &&
          this.jcdjh != ''
        ) {
          this.taskids = 6.3
        }
      },
      deep: true,
      immediate: true
    },
    jcdjh: {
      handler(i) {
        if (i != '') {
          this.clearmbfn()
        }
        if (
          i != '' &&
          this.hzbh != '' &&
          this.hzname != '' &&
          this.jcbh != ''
        ) {
          this.taskids = 6.3
        }
      },
      deep: true,
      immediate: true
    },
    id: {
      handler(i) {
        if (i == 1 && this.taskids == 8) {
          this.tiptext = '请按下曝光按钮'
        }
        if (i == 2 && this.taskids == 8) {
          this.tiptext = '请按下曝光按钮'
        }
        if (i == 3 && this.taskids == 8) {
          this.tiptext = '请按下曝光按钮'
        }
        if (i == 4 && this.taskids == 8) {
          this.tiptext = '请按下曝光按钮'
        }
        if (i == 5 && this.taskids == 8) {
          this.tiptext = '请按下曝光按钮'
        }
      }
    }
  },
  //方法集合
  methods: {
    // 不再次检测跳转到完成页面

    // 是否符合要求 二次提醒确认
    jlstipstwofn() {
      this.jlstipstwo = ''
       this.$router.push({
            name: 'allOver'
          })
    },
    // 记录数值完成
   jlsfn() {
   

     if (this.taskids != 11) { 
         this.taskid = 9
     }
     if (this.taskids == 11) { 
        
         this.jlstips = '某某人民医院某某品牌某某型号的DR机质量控制性能验收检测（信号传递特性STP检测）是否符合《中华人民共和国卫生行业标准WS 76-2020医用X线诊断设备质量控制检测规范》要求。'
     }
    },
    // 曝光提示确认
    bgqdfn() {
      if (this.taskids ==7.6) {
        this.taskid = 8
      }

    },
   
    // 开始曝光
    bgstart() {
      // 验证当前曝光次数 和 曝光项目 1
      if (this.id == 1 && this.taskids == 7.1) {
        // 项目1 曝光一次 60kv
        if (this.kv == 70&&this.mas == 1.6) {
         this.taskids = 7.11
           this.timer = setTimeout(() => {
              clearTimeout(this.timer)
            this.taskids = 7.12
             this.timer = setTimeout(() => {
               clearTimeout(this.timer)
                this.taskids = 7.13
              this.timer = setTimeout(() => {
              clearTimeout(this.timer)
               this.id = 2
               this.taskids = 7.2
                }, 1000)
                  }, 1000)
            }, 1000)
        } else {
          // 提示输入错误的曝光
          this.wtext = '输入错误'
          if (this.mas != 1.6) { 
            this.$refs.tybox2.classList.add('tymb')
            this.timer = setTimeout(() => {
         this.$nextTick(() => {
          this.$refs.tybox2.classList.remove('tymb')
          this.$refs.tybox1.classList.remove('tymb')
        })
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
          }
          if (this.kv != 70) { 
            this.$refs.tybox1.classList.add('tymb')
            this.timer = setTimeout(() => {
             this.$nextTick(() => {
          this.$refs.tybox2.classList.remove('tymb')
          this.$refs.tybox1.classList.remove('tymb')
        })
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
          }
         
        }
      }
      // 曝光项目2
      if (this.id == 2&& this.taskids == 7.2) {
       
         // 项目1 曝光2次 60kv
         if (this.kv == 70&&this.mas == 8) {
            this.taskids = 7.11
           this.timer = setTimeout(() => {
              clearTimeout(this.timer)
            this.taskids = 7.12
             this.timer = setTimeout(() => {
               clearTimeout(this.timer)
                this.taskids = 7.13
              this.timer = setTimeout(() => {
              clearTimeout(this.timer)
                this.id = 3
           this.taskids = 7.3
            }, 1000)
            }, 1000)
            }, 1000)
          
           
        } else {
          // 提示输入错误的曝光
          this.wtext = '输入错误'
          if (this.mas != 8) { 
            this.$refs.tybox2.classList.add('tymb')
            this.timer = setTimeout(() => {
              this.$refs.tybox2.classList.remove('tymb')
              this.$refs.tybox1.classList.remove('tymb')
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
          }
          if (this.kv != 70) { 
            this.$refs.tybox1.classList.add('tymb')
            this.timer = setTimeout(() => {
              this.$refs.tybox1.classList.remove('tymb')
              this.$refs.tybox2.classList.remove('tymb')
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
          }
         
        }
      }
      
 // 曝光项目3
 if (this.id == 3 && this.taskids == 7.3) {
       
  // 项目1 曝光2次 60kv
  if (this.kv == 70&&this.mas == 16) {
   
           this.timer = setTimeout(() => {
              clearTimeout(this.timer)
            this.taskids = 7.12
             this.timer = setTimeout(() => {
               clearTimeout(this.timer)
                this.taskids = 7.13
              this.timer = setTimeout(() => {
              clearTimeout(this.timer)
                    this.id = 4
                this.taskids = 7.4
            }, 1000)
            }, 1000)
            }, 1000)
    
 } else {
   // 提示输入错误的曝光
   this.wtext = '输入错误'
   if (this.mas != 16) { 
     this.$refs.tybox2.classList.add('tymb')
     this.timer = setTimeout(() => {
       this.$refs.tybox2.classList.remove('tymb')
       this.$refs.tybox1.classList.remove('tymb')
       this.wtext = ''
       clearTimeout(this.timer)
     }, 1000)
   }
   if (this.kv != 70) { 
     this.$refs.tybox1.classList.add('tymb')
     this.timer = setTimeout(() => {
       this.$refs.tybox1.classList.remove('tymb')
       this.$refs.tybox2.classList.remove('tymb')
       this.wtext = ''
       clearTimeout(this.timer)
     }, 1000)
   }
  
 }
 }
       // 曝光项目4
       if (this.id == 4 && this.taskids == 7.4) {
       
        // 项目1 曝光2次 60kv
        if (this.kv == 70&&this.mas == 32) {
         
           this.timer = setTimeout(() => {
              clearTimeout(this.timer)
            this.taskids = 7.12
             this.timer = setTimeout(() => {
               clearTimeout(this.timer)
                this.taskids = 7.13
              this.timer = setTimeout(() => {
              clearTimeout(this.timer)
                   this.id = 5
                this.taskids = 7.5
            }, 1000)
            }, 1000)
            }, 1000)
              
       } else {
         // 提示输入错误的曝光
         this.wtext = '输入错误'
         if (this.mas != 32) { 
           this.$refs.tybox2.classList.add('tymb')
           this.timer = setTimeout(() => {
             this.$refs.tybox2.classList.remove('tymb')
             this.$refs.tybox1.classList.remove('tymb')
             this.wtext = ''
             clearTimeout(this.timer)
           }, 1000)
         }
         if (this.kv != 70) { 
           this.$refs.tybox1.classList.add('tymb')
           this.timer = setTimeout(() => {
             this.$refs.tybox1.classList.remove('tymb')
             this.$refs.tybox2.classList.remove('tymb')
             this.wtext = ''
             clearTimeout(this.timer)
           }, 1000)
         }
        
       }
     }   // 曝光项目5
     if (this.id == 5 && this.taskids == 7.5) {
     
      // 项目1 曝光2次 60kv
       if (this.kv == 70 && this.mas == 50) {
        
         
                    this.timer = setTimeout(() => {
              clearTimeout(this.timer)
            this.taskids = 7.12
             this.timer = setTimeout(() => {
               clearTimeout(this.timer)
                this.taskids = 7.13
              this.timer = setTimeout(() => {
              clearTimeout(this.timer)
               this.taskids = 7.6
            }, 1000)
            }, 1000)
            }, 1000)
                 
       
     } else {
       // 提示输入错误的曝光
       this.wtext = '输入错误'
       if (this.mas != 50) { 
         this.$refs.tybox2.classList.add('tymb')
         this.timer = setTimeout(() => {
           this.$refs.tybox2.classList.remove('tymb')
           this.$refs.tybox1.classList.remove('tymb')
           this.wtext = ''
           clearTimeout(this.timer)
         }, 1000)
       }
       if (this.kv != 70) { 
         this.$refs.tybox1.classList.add('tymb')
         this.timer = setTimeout(() => {
           this.$refs.tybox1.classList.remove('tymb')
           this.$refs.tybox2.classList.remove('tymb')
           this.wtext = ''
           clearTimeout(this.timer)
         }, 1000)
       }
      
     }
   }
    },
    // 大步骤清理函数
    clearfn() {
      this.choiceid = 0
      this.gjltips = ''
      this.wpid = []
      this.choicetip = 0
      this.timer = null
      this.sum = 0
      this.jianguanj21hover = false
      this.jianguanj2hover = false
      this.jlstips = ''
      this.theWidth= 1
      this.theHeight = 1
      this.rotateds=0
      this.rotatedss= 0
      this.heightpx= 290
      this.widthpx = 270
      this.kv= 65
      this.mas= 1.5
      this.ms =100
      this.ma= 0
        this.heightsitpx = 50
      if (this.DR7_2) { 
        this.DR7_2.position.y=0
      }
      
    },
    // 清理四个输入框的描边
    clearmbfn() {
      if (this.$refs.hzbh.classList) {
        this.$refs.hzbh.classList.add('hsmb')
        this.$refs.hzname.classList.add('hsmb')
        this.$refs.jcbh.classList.add('hsmb')
        this.$refs.jcdjh.classList.add('hsmb')
      }
    },
    yclitemidfn(i) { 
      this.yclitemid = i
      this.yclimgid = 1
      if (i == 1) {
        this.ycldata = [
          {
            src: require(`@/images/ycl1.png`)
          },
           {
            src: require(`@/images/ycl2.png`)
          },
            {
            src: require(`@/images/ycl3.png`)
          }
          
        ]
      } else { 
         this.ycldata = [
          {
            src: require(`@/images/dq1.png`)
          },
           {
            src: require(`@/images/dq2.png`)
          },
            {
            src: require(`@/images/dq3.png`)
          }
        ]
      }
    },
    yclimgidfn(i) { 
      if (this.yclimgid + i<= 3&&this.yclimgid+i>=1){
        this.yclimgid =this.yclimgid+i
      }
    },
        gj() {
     
      if (this.heightpx <= 250) {
        this.heightpx += 10
        this.rotateds -= 5
        this.theHeight += 0.1
        // this.$refs.seen.theHeight += 0.1
      }
    },
    gjj() {
    
      if (this.heightpx >= 0) {
        if (this.heightpx >= 67) {
          this.rotateds += 5
          this.heightpx -= 10
          this.theHeight -= 0.1
        }
      }
    },
    kj() {
      if (this.widthpx <= 260) {
        this.widthpx += 10
        this.rotatedss += 5
        this.theWidth += 0.1
        // this.$refs.seen.theWidth += 0.1
      }
    },
    kjj() {
      if (this.widthpx >= 0) {
        if (this.widthpx >= 70) {
          this.rotatedss -= 5
          this.widthpx -= 10
          this.theWidth -= 0.1
        }
        // this.$refs.seen.theWidth -= 0.1
      }
    },

    // 验证视野
    shiyfn() {
      this.taskid = 6
    },
    // 验证sidfn
    sidfn() {
      if (this.heightsitpx != 90) {
         console.log('当前高度', this.heightsitpx)
        this.gjltips = '请将SID调至180cm'
      } else {
        this.taskid = 4
      }
    },
    // 调节sid增加
    sidsfn() {
      if (this.heightsitpx < 100) {
        this.$refs.sidsbox.classList.remove('tm')
        this.heightsitpx = this.heightsitpx + 5
        this.DR7_2.position.y += 0.015
      }
    },
    sidxfn() {
      if (this.heightsitpx > 0) {
        this.$refs.sidxbox.classList.remove('tm')
        this.heightsitpx = this.heightsitpx - 5
        this.DR7_2.position.y -= 0.015
      }
    },

    choiceidfn(i) {
      if (this.choicetip == 0) {
        this.choiceid = i
      }
    },
    choicefn() {
      if (this.taskids == 4) {
        if (this.choiceid == 1) {
          this.choicetip = 2
        } else {
          this.choicetip = 1
        }
      }
    },
    wpqdfn() {
      this.sum = this.sum + 1
      const requiredValues = [1, 2, 3, 6]
      const wpidSet = new Set(this.wpid) // 将数组转换为 Set 以便于查找
      const requiredSet = new Set(requiredValues)

      // 判断 wpid 是否只包含 1, 2, 3 且没有多余的元素
      if (
        wpidSet.size === requiredSet.size &&
        [...requiredSet].every((val) => wpidSet.has(val))
      ) {
        this.gjltips = '回答正确'
        this.timer = setTimeout(() => {
          this.gjltips = ''
          this.taskid = 2
          clearTimeout(this.timer)
        }, 1000)
      } else {
        this.gjltips = '回答错误'
        this.timer = setTimeout(() => {
          this.gjltips = ''
          clearTimeout(this.timer)
          this.wpid = []
          this.$nextTick(() => {
            if (this.$refs['normalImg1']) {
              this.$refs['normalImg1'][0].classList.add('tm')
            }
            if (this.$refs['normalImg2']) {
              this.$refs['normalImg2'][0].classList.add('tm')
            }
            if (this.$refs['normalImg3']) {
              this.$refs['normalImg3'][0].classList.add('tm')
            }
            if (this.$refs['normalImg6']) {
              this.$refs['normalImg6'][0].classList.add('tm')
            }
          })
        }, 1000)
        if (this.sum >= 3) {
          this.wpid = [1, 2, 3, 6]
        }
      }
    },

    wpidfn(i) {
      // 检查数组中是否已存在相同的元素
      const index = this.wpid.indexOf(i)
      // 如果存在相同的元素，先删除它
      if (index !== -1) {
        this.wpid.splice(index, 1)
        return
      }
      // 然后再将元素添加到数组中
      this.wpid.push(i)
    },
    ycfns() {
      if (this.rightpx == -900) {
        this.rightpx = 10
      }
    },
    ycfn() {
      if (this.rightpx == 10) {
        this.rightpx = -900
      }
    },
    jbshowfn() {
      this.$nextTick(() => {
        this.jbshow = !this.jbshow
      })
    },
    qhfn(item) {
      const foundindex = this.jboxdata.findIndex(
        (data) => data.bsid == item.bsid
      )
      if (foundindex !== -1) {
        // 交换 bsid 和 name 的值
        const tempBsid = this.jboxdata[foundindex].bsid
        const tempName = this.jboxdata[foundindex].name
        // 把找到的项替换为第一个项的值
        this.jboxdata[foundindex].bsid = this.jboxdata[0].bsid
        this.jboxdata[foundindex].name = this.jboxdata[0].name
        this.bsid = item.bsid
        // 把第一个项替换为目标项的值
        this.jboxdata[0].bsid = tempBsid
        this.jboxdata[0].name = tempName
      } else {
        console.log('未找到匹配的项')
      }
    },
    clickItem(i) {
      if (i == 1.2) {
        this.taskids = 1.3
      }
      if (i == 'DR8_1' && this.taskids == 2) {
        this.wtext = '已取出滤线栅'
         this.timer = setTimeout(() => {
          this.taskid = 3
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
      }
      if ((i == 'TanCeQi4'||i=='DR8_1')&&this.taskids == 4.1) {
        this.taskid = 5
      }
      if (i == '1tongban') {
        // this.taskid = 7
        this.wtext = '铜板已挡住线束器出束口'
         this.timer = setTimeout(() => {
          this.taskids = 6.1
              this.wtext = ''
              clearTimeout(this.timer)
            }, 1000)
      }
      if ((i == 'DR8_1' || i == 'BiJiBenDianNao1') && this.taskids == 8) {
        this.taskids = 8.1
      }
      if (i == '跳转到11') { 
        this.taskid = 11
      }
    },
    tiptextfn(i) {
      this.tiptext = i
     }

  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.init()
  },
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {}
}
